<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>个人游戏详情</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="__PUBLIC__/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/layuiadmin/style/admin.css" media="all">
<body layadmin-themealias="default" style="">
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item" style="height: 20px;line-height: 20px;">
                <div class="layui-inline" style="margin-right: 0px;">
                     <span class="layui-breadcrumb">
                        <a href="">首页/游戏详情</a>
                        </span>
                </div>
                <div class="layui-inline" style="right: 0px;position: absolute;">
                    <a class="layui-btn layui-btn-small" style="line-height:20px;margin-top:-6px;float:right" href="javascript:location.replace(location.href);" title="刷新">
                        &nbsp;<i class="layui-icon layui-icon-refresh-3" style="line-height:18px;left: 12px;top:12px;"></i>&nbsp;
                    </a>
                </div>
            </div>
        </div>
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline" style="margin-right: 0px;">
                    <label class="layui-form-label">时间</label>
                    <div class="layui-input-inline">
                        <input class="layui-input" placeholder="时间" name="start_time" id="start" value="{$time}">
                    </div>
                    <div class="layui-input-inline">
                        <input class="layui-input" placeholder="结束时间" name="end_time" id="end" value="{$end}">
                    </div>
                    <input type="hidden" name="gameid" placeholder="游戏ID"  class="layui-input" value="{$gameid}"  style="width:200px;">

                </div>
                <div class="layui-inline" style="margin-right: 0px;">
                    <div class="layui-input-inline">
                        <select name="serverid">
                            <option value=''  selected>--全部--</option>
                            <volist name="selects" id="vo">
                                <option value='{$vo.serverid}' >{$vo.servername}</option>
                            </volist>
                        </select>
                    </div>
                </div>

                <div class="layui-inline" style="margin-right: 0px;">
                    <button class="layui-btn layuiadmin-btn-admin" lay-submit="" lay-filter="LAY-user-back-search">
                        搜索
                    </button>
                </div>
            </div>
        </div>
        <div class="layui-card-body">
            <table class="layui-table" id="admin_table" lay-filter="admin_table"></table>
            <script type="text/html" id="table_game_player">

            </script>
        </div>
    </div>

    <div class="layui-card">
        <div class="layui-card-header">数据概览</div>
        <div class="layui-card-body">

            <div class="layui-carousel layadmin-carousel layadmin-dataview" data-anim="fade" lay-filter="LAY-index-dataview" lay-anim="fade" lay-indicator="inside" lay-arrow="none" style="width: 100%; height: 280px;">
                <div carousel-item="" id="LAY-index-dataview">
                    <div class="layui-this" _echarts_instance_="1541060407213" style="-webkit-tap-highlight-color: transparent; -webkit-user-select: none; background-color: rgba(0, 0, 0, 0);">
                        <div style="position: relative; overflow: hidden; width: 854px; height: 332px;"><div data-zr-dom-id="bg" class="zr-element" style="position: absolute; left: 0px; top: 0px; width: 854px; height: 332px; -webkit-user-select: none;"></div><canvas width="854" height="332" data-zr-dom-id="0" class="zr-element" style="position: absolute; left: 0px; top: 0px; width: 854px; height: 332px; -webkit-user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></canvas><canvas width="854" height="332" data-zr-dom-id="1" class="zr-element" style="position: absolute; left: 0px; top: 0px; width: 854px; height: 332px; -webkit-user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></canvas><canvas width="854" height="332" data-zr-dom-id="_zrender_hover_" class="zr-element" style="position: absolute; left: 0px; top: 0px; width: 854px; height: 332px; -webkit-user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></canvas></div></div>
                </div>
               <!-- <div class="layui-carousel-ind">
                    <ul>
                        <li class="layui-this"></li>
                    </ul>
                </div>-->
               <!-- <button class="layui-icon layui-carousel-arrow" lay-type="sub"></button>
                <button class="layui-icon layui-carousel-arrow" lay-type="add"></button>-->

            </div>

        </div>
    </div>



</div>

<script src="__PUBLIC__/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '__PUBLIC__/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table','laydate',"carousel","echarts",'admin'], function(){
        var $ = layui.$
            ,form = layui.form
            ,admin = layui.admin
            ,table = layui.table,laydate = layui.laydate,a=layui.carousel,i=layui.echarts;

        var  l=[],n=[];
        var r=$("#LAY-index-dataview").children("div");
        var o=function(e){l[e]=i.init(r[e],layui.echartsTheme),l[e].setOption(n[e]), admin.resize(function(){l[e].resize()})};

        //时间范围
        laydate.render({
            elem: '#start'
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#end'
            ,type: 'datetime'
        });

        $(".layuiadmin-btn-admin").on("click",function(){
            var gameid = $("input[name=gameid]").val();
            var time = $("#start").val();
            var end = $("#end").val();
            var serverid = $("select[name=serverid]").val();

            table.reload('admin_table',{
                page:{
                    curr:1
                }
                ,where:{gameid:gameid,time:time,end:end,serverid:serverid}
            });
        });

       /* table.on('toolbar(admin_table)', function(obj){
            var data = obj.data;
           // console.log(data);
            if(data===undefined){
                layer.msg('数据为空');
            }else{
               // console.log(data.time);
               // console.log(data.currentscore);
               // n=[]
            }
          //  layer.msg(data);
        });*/

        var gameid = $("input[name=gameid]").val();
        var time = $("#start").val();
        var indxe = layer.load(3);
        //执行一个 table 实例
        table.render({
            elem: '#admin_table'
            ,url: 'getgame_player' //数据接口
            ,title: '游戏详情'
            ,loading:true
            ,toolbar: true //开启工具栏，此处显示默认图标，可以自定义模板，详见文
            ,defaultToolbar:['filter','exports']
            ,page: true //开启分页
            ,limits:[20,40,60,80,100,150]
            ,cols: [[ //表头
                {field: 'time', title: '时间',align:'center', width:200}
                ,{field: 'gameid', align:'center', title: '游戏ID', width:120}
                ,{field: 'nickname', title: '玩家昵称', width:120}
                ,{field: 'ServerName', title: '游戏房间', width:140}
                ,{field: 'tax', title: '税收'}
                ,{field: 'betscore', title: '下注金额'}
                ,{field: 'rewardscore', title: '开奖金额'}
                ,{field: 'caculscore', title: '盈亏'}
                ,{field: 'currentscore', title: '当前金币'}

            ]]
            ,where:{gameid:gameid,time:time}
            ,done:function (res) {
                layer.close(indxe);
                var data = res.data;
                var datestr =[];
                var currentscore =[];
                var y2 =0,min =0,y3 =0,y4 =0,max=0;
                if(data.length != 0){
                    for (var i=data.length-1;i>=0;i--) {
                        datestr.push(data[i]['time'].substr(10,data[i]['time'].length));
                        currentscore.push(data[i]['currentscore']);
                    }
                    max=  Math.max.apply(null,currentscore);
                    min=  Math.min.apply(null,currentscore);
                    console.log(currentscore);
                    console.log(datestr);
                }
                min = Math.floor(min);
                max = Math.ceil(max);
                n=[{title:{text:"今日趋势",x:"center",textStyle:{fontSize:14}},tooltip:{trigger:"axis"}
                ,xAxis:[{type:"category",boundaryGap:!1,axisLabel:{interval:0},data:datestr}]
                    ,yAxis:[{name:'金币数',type:'value',min:min,max:max}]
                    ,series:[{name:"金币数",type:"line",smooth:!0,itemStyle:{normal:{areaStyle:{type:"default"}}},data:currentscore}]}];
                o(0);

               // axisLabel:{interval:0},
            }
        });
    });
</script>
</body>
</html>